package com.bruce.springbootDemo.web.service.impl;

import com.bruce.springbootDemo.config.redis.RedisUtil;
import com.bruce.springbootDemo.web.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by bruce on 18/11/28 -- 14:45
 */
@Service(value = "UserServiceImpl")
public class UserServiceImpl implements IUserService {
    @Autowired
    private RedisUtil redisUtil;
    //
    private String NAME = "name";

    @Override
    public String getName() {
        return (String) redisUtil.get(NAME);
    }

    @Override
    public void setName(String name) {
        redisUtil.set(NAME, name);
    }

    @Override
    public String fetchName(String name) {
        String cacheName = getName();
        setName(name);
        return cacheName;
    }
}
